package com.jubaozan.framework.sentinel.springmvc.listener;

import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
import com.jubaozan.framework.sentinel.listener.AbstractRulePropertyListener;
import java.util.List;
import lombok.RequiredArgsConstructor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author jiangjinwu
 * @version 1.0
 * @since 2025/7/19 11:52
 */

@Slf4j
@Component
public class DegradePropertyListener extends AbstractRulePropertyListener<DegradeRule> {

    public DegradePropertyListener() {
        super(DegradeRule.class);
    }

    @Override
    protected void doLoad(List<DegradeRule> conf) {
        DegradeRuleManager.loadRules( conf);
        log.info("接收到熔断配置加载: {}", conf);
    }

    @Override
    protected String getRedisKey() {
          return ruleKeyConstant.getDegradeRuleKey();
    }
}
